/**
 *  example2.vala
 *
 *  Copyright (c) 2007 Marcelo Lira dos Santos <setanta@gmail.com>
 *
 *  Author: Marcelo Lira dos Santos <setanta@gmail.com>
 *
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU General Public License as
 *  published by the Free Software Foundation; either version 2 of the
 *  License, or (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 *  USA
 */

using GLib;
using Gtk;

namespace ValaDemo
{
    public class Example2 : Window
    {
        [Widget] protected Entry entry1;
        [Widget] protected Label label1;
        [Widget] protected Label label2;
        [Widget] protected Button button1;

        construct {
            title = "Exemplo 2";
            icon_name = "gtk-dialog-info";
            set_default_size(260, -1);

            var vbox1 = new VBox(false, 4);
            vbox1.border_width = 4;

            var hbox1 = new HBox(false, 4);

            label1 = new Label("Escreva algo:");
            hbox1.pack_start(label1, false, false, 0);

            entry1 = new Entry();
            hbox1.pack_start(entry1, true, true, 0);

            button1 = new Button.from_stock("gtk-apply");
            button1.clicked += on_button1_clicked;
            hbox1.pack_start(button1, false, false, 0);

            vbox1.pack_start(hbox1, false, true, 0);

            var separator = new HSeparator();
            vbox1.pack_start(separator, false, true, 2);

            label2 = new Label("");
            label2.xalign = 0.0;
            label2.set_line_wrap(true);
            vbox1.pack_start_defaults(label2);

            add (vbox1);

            destroy += Gtk.main_quit;
        }

        void on_button1_clicked (Button button) {
            label2.set_markup("<b>Você escreveu:</b> " + entry1.text);
        }
    }

    static int main (string[] args) {
        Gtk.init(out args);

        var ex2 = new Example2();
        ex2.show_all();

        Gtk.main();

        return 0;
    }
}
